package com.wa.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 操作日志模板枚举
 * @Author Dawn
 * @Date 2021/10/28 11:22
 */
public enum OperationLogTemplateEnum {
    LOGIN(10, "【用户ID：%userId%】、【用户登录名：%userLoginName%】【员工名称：%employeeName%】登录【%result%】"),
    RESET_PASSWORD(20, "重置密码【%result%】"),
    USER_RELEVANCE(30, "【ID：%userId%】【账号名：%userName%】关联【关联ID：%employeeId%】【姓名：%employeeNameCn%】"),
    UPDATE_USER_BY_GROUP(49, "【用户ID：%userId%】、【用户登录名：%userLoginName%】【员工名称：%employeeName%】【部门id：%deptId%】【部门名称：%deptName%】 修改用户【%result%】"),
    DIS_RELEVANCE_STATUS(50, "【ID：%userId%】、【账号名：%userLoginName%】取消关联【关联ID:%id%】【姓名：%employeeName%】"),
    EDIT_ROLE_GROUP(60, "【用户ID：%userId%】、【用户登录名：%userLoginName%】【员工名称：%employeeName%】【角色id：%roleId%】修改角色【%result%】"),
    USER_OPEN(70, "【启用】了【用户ID：%userId%】【名称：%employeeName%】"),
    USER_CLOSE(80, "【禁用】了【用户ID：%userId%】【名称：%employeeName%】"),
    ROLE_DEACTIVATE(90, "【停用】了【角色ID：%roleId%】【角色名称：%roleName%】"),
    ROLE_ENABLE(100, "【启用】了【角色ID：%roleId%】【角色名称：%roleName%】"),
    PERMISSION_DEACTIVATE(110, "【停用】了【权限ID：%id%】【权限名称：%permissionName%】"),
    PERMISSION_ENABLE(120, "【启用】了【权限ID：%id%】【权限名称：%permissionName%】"),
    UPDATE_PASSWORD(130, "修改密码【%result%】"),
    MERGE_DEPT(140, "部门合并【%from%】==>【%to%】"),
    ;

    private int code;
    private String desc;

    OperationLogTemplateEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    private static final Map<Integer, OperationLogTemplateEnum> logTemplateMap = new HashMap<>();

    static {
        for (OperationLogTemplateEnum olt : OperationLogTemplateEnum.values()) {
            logTemplateMap.put(olt.getCode(), olt);
        }
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }


    public static OperationLogTemplateEnum getByCode(Integer code) {
        return logTemplateMap.get(code);
    }

}
